package com.example.neusoft.yuejian_12.Fragment;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.neusoft.yuejian_12.Adapter.ClubMasterAdapter;
import com.example.neusoft.yuejian_12.JavaBean.Club;
import com.example.neusoft.yuejian_12.Listener.ClubDetailListener;
import com.example.neusoft.yuejian_12.Model.ClubModel;
import com.example.neusoft.yuejian_12.R;

import java.util.List;

/**
 * Created by admin on 2017/10/24.
 */

public class ClubInfoFragment extends Fragment {
    private RecyclerView recyclerView;
    private Context mContext;
    private String id;
    private Club info;
    private ImageView masterPhoto;
    private TextView intro,time,place,mastername;
    private  String  introduction,open_time,province_name,city_name,district_name;
    private List<Club.ClubteacherEntity> Data;
    ClubDetailListener clubDetailListener = new ClubDetailListener() {
        @Override
        public void onResponse(Club listBean) {
            info = listBean;
            initData();


        }


        @Override
        public void onFail(String msg) {

        }
    };
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState)
    {
        View view=inflater.inflate(R.layout.activity_clubdetail_fragment, container, false);
        intro = (TextView) view.findViewById(R.id.intro);
        time = (TextView) view.findViewById(R.id.time);
        mastername=(TextView)view.findViewById(R.id.master_name);
        masterPhoto=(ImageView)view.findViewById(R.id.master_pic);
        place=(TextView)view.findViewById(R.id.place);
        final Bundle bundle =getActivity().getIntent().getExtras();
        id = bundle.getString("id");
        recyclerView = (RecyclerView) view.findViewById(R.id.rv_clubmaster);
        recyclerView.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        ClubModel model = new ClubModel();
        model.getdetail(id, clubDetailListener);
        return  view;
    }

    public  void initData(){
        introduction=info.getIntroduction().replaceAll("</p>","").replaceAll("<p>","").replaceAll("<br/>","");
        open_time=info.getOpen_time();
        district_name=info.getProvince_name()+info.getCity_name()+info.getDistrict_name();
        time.setText("营业时间："+open_time);
        intro.setText("简介："+introduction);
        place.setText("地址："+district_name);

        Data=info.getClubteacher();
        recyclerView.setAdapter(new ClubMasterAdapter(getActivity(),Data));


    }




}
